package xyz.lwm.lazycat.beans;

import lombok.Getter;

import java.lang.reflect.Type;
import java.util.Objects;

/**
 * 实例的注入依赖
 *
 * @author lwm
 */
@Getter
public class Injection extends Dependency {

    /**
     * 属性被注入时的字段名称
     */
    private final String property;

    public Injection(Class<?> owner, String name, Type type, String property) {
        super(owner, name, type);
        this.property = property;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Injection)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        Injection injection = (Injection) o;
        return Objects.equals(property, injection.property);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), property);
    }

}
